Return to doc.sitecore.com

Valid for Sitecore 5.1.1
Using Visual Studio .Net

1.  Creating a project

Create a Visual Studio project (this should generally be done only once for each instance of Sitecore). 

To create the project:

  1. Open Visual Studio .NET.
  2. From the File menu select New Project.
  3. Select the language you would like to use (Sitecore internally uses C# exclusively).
  4. Select New Project in Existing Folder.


  5. Enter a name for your project.  Names should not begin with numbers or contain special characters. 
  6. Enter the address of the website hosting the project, typically http://localhost in development.


  7. In Solution Explorer, press the Show All Files button.


  8. Right-click on References and choose Add Reference.


  9. Browse to the /bin/ folder of the project and select Sitecore.Kernel.


  10. Right-click on /web.config and select Include In Project.


  11. Right-click on the /xsl/ directory and select Include in Project.
  12. Open the /layouts/ directory, right-click on each Layout or Sublayout and choose Include in Project. 





    Layouts typically do not contain code-behind; Sublayouts commonly contain code-behind.  To be prompted to create a code behind, exclude a file from the project temporarily, then add it again.
  13. Optionally, open the /sitecore modules/ directory in Windows Explorer and create one or more folders as needed.  Return to Visual Studio, refresh Solution Explorer and include these directories in the project.
  14. Right-click on the name of the project in Solution Explorer and choose Properties. 



    Set Assembly Name and Default Namespace.

2.  Add code-behind to layouts or sublayouts.

To add code-behind to a Layout:

  1. Open the project in Microsoft® Visual Studio .NET.
  2. Open Solution Explorer and navigate to the folder containing the Layout (usually /layouts).
  3. If the Layout is already included in the project, right-click on it and exclude the Layout.
  4. Right-click on the Layout and add it to the Project; Visual Studio will suggest that a code-behind be created.

3.  Enable IntelliSense

NOTE: The following information does not apply to Visual Studio 2005.  Microsoft changed the file format for IntelliSense in VS 2005.  We do not currently have an IntelliSense source for Xml Controls and Layouts for Visual Studio 2005.

Perform the following steps to enable IntelliSense in Visual Studio when editing Xml Controls and Xml Layouts.